/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-12-30 09:50:40
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2024-06-04 14:24:17
 * @FilePath: \cxl-driving-training\src\apis\clue\index.ts
 */
import axios from '../../axios/index'

export interface cluePageInterface {
    current: number
    size: number
    followStatus?: number //跟进状态(0.待跟进；1.跟进中；2.已放弃; 3.待报名；4.已报名）
    phone?: string
    customerName?: string
    dataSources?: string
    endCreateTime?: string
    startCreateTime?: string
    referrer?: string
    customerType?: number
    followerAssignStatus?: number
    transactionChannel?: string
    systemSource?: number
}

export const cluePage = (params: cluePageInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/manage/clues',
        params
    })
}

export interface clueOperateInterface {
    areaName?: string
    cityName?: string
    createTime?: string
    customerId?: string
    customerName?: string
    dataSource?: string
    phone?: string
    referrerName?: string
    referrerPhone?: string
    schoolId?: string
    schoolName?: string
    storeName?: string
    systemSource?: number
    viewedClassName?: string
}

export const addClue = (data: clueOperateInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/manage/clues',
        data
    })
}

export interface clueOperationInterface {
    followMsg?: string
    followStatus?: number
    id?: string
    follower?: string
}

export const clueEdit = (data: clueOperationInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/manage/clues/edit-follow-up',
        data
    })
}

//线索跟进记录列表
export const clueListById = (clueId: string) => {
    return axios({
        method: 'get',
        url: '/api/system/manage/clues/list-follow-up',
        params: { clueId }
    })
}

//数据来源字典
export const dataSourceDict = () => {
    return axios({
        method: 'get',
        url: '/api/system/manage/clues/data-source'
    })
}

//公海线索分页
export const clueHighSeasPage = (params: cluePageInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/manage/clues-high-seas',
        params
    })
}

//线索同步
export const clueSync = (data: { syncType: number; endTime: string; startTime: string }) => {
    return axios({
        method: 'post',
        url: '/api/system/manage/clues/sync',
        data
    })
}

//分配跟进人
export const clueAllocation = (data: { clueIds: string[]; follower: string }) => {
    return axios({
        method: 'post',
        url: '/api/system/manage/clues/assign-follower',
        data
    })
}

//成交渠道list
export const dealChannelList = () => {
    return axios({
        method: 'get',
        url: '/api/system/manage/clues/transaction-channels'
    })
}

//批量导入
export const importClues = (file: File) => {
    const fileFormData = new FormData()
    fileFormData.append('file', file)
    return axios({
        method: 'post',
        url: '/api/system/manage/clues/importExcelList',
        data: fileFormData
    })
}
